what to mount. Add an options string to the libfsimage API.
Signed-off-by: John Levon <john.levon@sun.com>
static pthread_mutex_t fsi_lock = PTHREAD_MUTEX_INITIALIZER;
-fsi_t *fsi_open_fsimage(const char *path, uint64_t off)
+fsi_t *fsi_open_fsimage(const char *path, uint64_t off, const char *options)
{
fsi_t *fsi = NULL;
int fd;
fsi->f_data = NULL;
pthread_mutex_lock(&fsi_lock);
- err = find_plugin(fsi, path);
+ err = find_plugin(fsi, path, options);
pthread_mutex_unlock(&fsi_lock);
if (err != 0)
goto fail;
typedef struct fsi fsi_t;
typedef struct fsi_file fsi_file_t;
-fsi_t *fsi_open_fsimage(const char *, uint64_t);
+fsi_t *fsi_open_fsimage(const char *, uint64_t, const char *);
void fsi_close_fsimage(fsi_t *);
int fsi_file_exists(fsi_t *, const char *);
}
static int
-fsig_mount(fsi_t *fsi, const char *path)
+fsig_mount(fsi_t *fsi, const char *path, const char *options)
{
fsig_plugin_ops_t *ops = fsi->f_plugin->fp_data;
fsi_file_t *ffi;
bzero(fsi->f_data, sizeof (fsig_data_t));
- if (!ops->fpo_mount(ffi)) {
+ if (!ops->fpo_mount(ffi, options)) {
fsip_file_free(ffi);
free(fsi->f_data);
fsi->f_data = NULL;
typedef struct fsig_plugin_ops {
int fpo_version;
- int (*fpo_mount)(fsi_file_t *);
+ int (*fpo_mount)(fsi_file_t *, const char *);
int (*fpo_dir)(fsi_file_t *, char *);
int (*fpo_read)(fsi_file_t *, char *, int);
} fsig_plugin_ops_t;
return (ret);
}
-int find_plugin(fsi_t *fsi, const char *path)
+int find_plugin(fsi_t *fsi, const char *path, const char *options)
{
fsi_plugin_t *fp;
int ret = 0;
for (fp = plugins; fp != NULL; fp = fp->fp_next) {
fsi->f_plugin = fp;
- if (fp->fp_ops->fpo_mount(fsi, path) == 0)
+ if (fp->fp_ops->fpo_mount(fsi, path, options) == 0)
goto out;
}
typedef struct fsi_plugin_ops {
int fpo_version;
- int (*fpo_mount)(fsi_t *, const char *);
+ int (*fpo_mount)(fsi_t *, const char *, const char *);
int (*fpo_umount)(fsi_t *);
fsi_file_t *(*fpo_open)(fsi_t *, const char *);
ssize_t (*fpo_read)(fsi_file_t *, void *, size_t);
void *ff_data;
};
-int find_plugin(fsi_t *, const char *);
+int find_plugin(fsi_t *, const char *, const char *);
#ifdef __cplusplus
};
#include <inttypes.h>
static int
-ext2lib_mount(fsi_t *fsi, const char *name)
+ext2lib_mount(fsi_t *fsi, const char *name, const char *options)
{
int err;
char opts[30] = "";
/* check filesystem types and read superblock into memory buffer */
int
-ext2fs_mount (fsi_file_t *ffi)
+ext2fs_mount (fsi_file_t *ffi, const char *options)
{
int retval = 1;
/* check filesystem types and read superblock into memory buffer */
int
-reiserfs_mount (fsi_file_t *ffi)
+reiserfs_mount (fsi_file_t *ffi, const char *options)
{
struct reiserfs_super_block super;
int superblock = REISERFS_DISK_OFFSET_IN_BYTES >> SECTOR_BITS;
/* read superblock and check fs magic */
int
-ufs_mount(fsi_file_t *ffi)
+ufs_mount(fsi_file_t *ffi, const char *options)
{
if (/*! IS_PC_SLICE_TYPE_SOLARIS(current_slice) || */
!devread(ffi, UFS_SBLOCK, 0, UFS_SBSIZE, (char *)SUPERBLOCK) ||
static PyObject *
fsimage_open(PyObject *o, PyObject *args, PyObject *kwargs)
{
- static char *kwlist[] = { "name", "offset", NULL };
- char * name;
+ static char *kwlist[] = { "name", "offset", "options", NULL };
+ char *name;
+ char *options = NULL;
uint64_t offset = 0;
fsimage_fs_t *fs;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|L", kwlist,
- &name, &offset))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|Ls", kwlist,
+ &name, &offset, &options))
return (NULL);
if ((fs = PyObject_NEW(fsimage_fs_t, &fsimage_fs_type)) == NULL)
return (NULL);
- if ((fs->fs = fsi_open_fsimage(name, offset)) == NULL) {
+ if ((fs->fs = fsi_open_fsimage(name, offset, options)) == NULL) {
PyErr_SetFromErrno(PyExc_IOError);
return (NULL);
}
"open(name, [offset=off]) - Open the given file as a filesystem image.\n"
"\n"
"name - name of file to open.\n"
- "offset - offset of file system within file image.\n");
+ "offset - offset of file system within file image.\n"
+ "options - mount options string.\n");
static struct PyMethodDef fsimage_module_methods[] = {
{ "open", (PyCFunction)fsimage_open,